package com.ustc.phoenix.mybatis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.InputStream;

/**
 * Created by firephoenix on 7/3/16.
 */
@Configuration
public class MybatisConf {
    @Bean
    public SqlSessionFactory sqlSessionFactory(@Value("com/ustc/phoenix/mybatisConf/mybatis-config.xml")String resource) throws Exception{
        InputStream inputStream= Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        return sqlSessionFactory;
    }
}
